<template>
  <Modal
    v-model:active="ElemEditModalVueActive"
    transfer
    title="单元编辑"
    :width="540"
    confirm-text="确定"
    @confirm="excuteElemEdit"
  >
    <NativeScroll use-y-bar height="100%" scroll-style="padding: 24px;">
      <Row :gap="[8]">
        <ConfigProvider :props="providedProps">
          <div style="padding: 10px">
            <div style="padding: 10px">
              <div>
                <Column :flex="1">
                  <div class="title">
                    <div class="title_color"></div>
                    <div class="title_content">操作：</div>
                  </div>
                </Column>
                <Column>
                  <RadioGroup v-model:value="radioValue">
                    <div flex>
                      <Radio
                        v-for="item in op_Options"
                        :key="item.value"
                        :label="item.label"
                        :disabled="item.disabled"
                        :name="'select_radio'"
                      >
                        {{ item.label }}
                      </Radio>
                    </div>
                  </RadioGroup>
                </Column>
              </div>
            </div>
          </div>
        </ConfigProvider>
      </Row>
    </NativeScroll>
  </Modal>
</template>
<script setup lang="ts">
import { ref } from "vue";
import {
  Modal,
  Divider,
  RadioGroup,
  FormItem,
  ConfigProvider,
  Radio,
  NativeScroll,
  Row,
  Column,
  Message,
} from "cax-ui";
import { storeToRefs } from "pinia";
import { useCoreStore, _global } from "@/UI/store";

const coreStore = useCoreStore();

let { ElemEditModalVueActive } = storeToRefs(coreStore);

let radioValue = ref();

const providedProps = {
  default: { clearable: true },
  formItem: { required: true },
};
const op_Options = [
  {
    label: "分离/detach",
    value: 1,
    disabled: false,
  },
  {
    label: "改变单元阶数为1阶",
    value: 2,
    disabled: false,
  },
  {
    label: "改变单元阶数为2阶",
    value: 3,
    disabled: true,
  },
  {
    label: "设置属性",
    value: 4,
    disabled: true,
  },
];
function excuteElemEdit() {
  const selectedOp = op_Options.filter(
    (item) => item.label === radioValue.value
  )[0];
  if (selectedOp) {
    switch (selectedOp.value) {
      case 1:
        _global.Engine.mesh.detach().then(() => {
          console.log("finish detach");
        });
        break;
      case 2:
        break;
      case 3:
        break;
      case 4:
        break;
    }
  } else {
    Message.error("未选择操作!");
  }
}
</script>

<style scoped lang="less">
:deep(.vxp-form) {
  display: flex;
  align-items: center;
}
.title {
  display: flex;
  align-items: center;
  margin-bottom: 16px;

  .title_color {
    width: 4px;
    height: 12px;
    background: #339af0;
    margin-right: 8px;
  }
  .title_content {
    opacity: 1;
    font-family: PingFang SC;
    font-size: 14px;
    font-weight: 600;
    line-height: 22px;
    letter-spacing: 0em;
    font-variation-settings: "opsz" auto;
    /* content/主要一级primary */
    /* 样式描述：--vxp-content-color-primary */
    color: #212529;
  }
}
</style>
